package lq;

import java.util.Scanner;

public class lq2016 {
    public static void main(String[] args){
        Scanner in = new Scanner(System.in);
        int n,m;
        m=0;
        while (true){
            n=in.nextInt();
            if (n==0){
                break;
            }
            int[] a =new int[n];
            for (int i=0;i<a.length;i++){
                a[i]=in.nextInt();
            }
            int xb=0,min=a[0];
            for (int j=1;j<a.length;j++){
                if (min>a[j]){
                    min=a[j];
                    xb=j;
                }
            }
            if (min!=a[0]){
                a[xb]=a[0];
                a[0]=min;
            }
            for (int y:a){
                if (m==0){
                    System.out.print(y);
                    m++;
                }
                else{
                    System.out.print(" "+y);
                }
            }
            System.out.println();
            m=0;
        }
    }
}
